package cn.tedu.zhyl.system.controller;

import cn.tedu.zhyl.base.response.JsonResult;
import cn.tedu.zhyl.system.pojo.dto.SysMenuDTO;
import cn.tedu.zhyl.system.pojo.vo.SysMenuVO;
import cn.tedu.zhyl.system.service.SysMenuService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/system/menu/")
public class SysMenuController {
    @Autowired
    private SysMenuService sysMenuService;
    @GetMapping("menuList")
    public JsonResult<List<SysMenuVO>> getMenus(){
        List<SysMenuVO> menus = sysMenuService.getList();
        return JsonResult.ok(menus);
    }

    @PostMapping("save")
    public JsonResult save(@RequestBody SysMenuDTO sysMenuDTO){
        sysMenuService.save(sysMenuDTO);
        return JsonResult.ok();
    }

    @GetMapping("delete/{id}")
    public JsonResult deleteById(@PathVariable("id")Integer id){
        sysMenuService.deleteById(id);
        return JsonResult.ok();
    }
}
